import { BST } from './BST'
import { LinkedList } from './LinkedList'
import { AVLTree } from './AVLTree'


export class BSTSet {
    constructor() {
        this.bst = new BST()

    }

    getSize() {
        return this.bst.getSize()
    }

    isEmpty() {
        return this.bst.isEmpty()
    }

    add(e) { // O(logn)
        this.bst.add(e)
    }

    contains(e) { // O(logn)
        return this.bst.contains(e)
    }

    remove(e) { // O(logn)
        this.bst.remove(e)
    }

}


export class LinkedListSet {
    constructor() {
        this.list = new LinkedList()

    }

    getSize() {
        return this.list.getSize()
    }

    isEmpty() {
        return this.list.isEmpty()
    }

    contains(e) { // O(n)
        return this.list.contains(e)
    }

    add(e) { // O(n)
        if (!this.list.contains(e)) {
            this.list.addFirst(e)
        }
    }

    remove(e) { // O(n)
        this.list.removeElement(e)
    }

}


export class AVLSet {
    constructor() {
        this.avl = new AVLTree()
    }

    getSize() {
        return this.avl.getSize()
    }

    isEmpty() {
        return this.avl.isEmpty()
    }

    add(e) {
        this.avl.add(e, null)
    }

    contains(e) {
        return this.avl.contains(e)
    }

    remove(e) {
        return this.avl.remove(e)
    }
}